package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.Province;
import com.pgybook.db.entity.domain.ProvinceEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface ProvinceMapper {
    int countByExample(ProvinceEx example);

    int deleteByExample(ProvinceEx example);

    @Delete({
            "delete from province",
            "where PRVID = #{prvid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer prvid);

    @Insert({
            "insert into province (NAME, LIBID, ",
            "DESCRIPTION, CODE)",
            "values (#{name,jdbcType=VARCHAR}, #{libid,jdbcType=INTEGER}, ",
            "#{description,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "prvid", before = false, resultType = Integer.class)
    int insert(Province record);

    int insertSelective(Province record);

    List<Province> selectByExample(ProvinceEx example);

    @Select({
            "select",
            "PRVID, NAME, LIBID, DESCRIPTION, CODE",
            "from province",
            "where PRVID = #{prvid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Province selectByPrimaryKey(Integer prvid);

    int updateByExampleSelective(@Param("record") Province record, @Param("example") ProvinceEx example);

    int updateByExample(@Param("record") Province record, @Param("example") ProvinceEx example);

    int updateByPrimaryKeySelective(Province record);

    @Update({
            "update province",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "LIBID = #{libid,jdbcType=INTEGER},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR},",
            "CODE = #{code,jdbcType=VARCHAR}",
            "where PRVID = #{prvid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Province record);
}
